home *** CD-ROM | disk | FTP | other *** search
/ Die Speccy' 97 / Die Speccy' 97.iso / amiga_system / the_aminet / comm / mebbs / adrtcdrom2_9.lha / adrtcdrom.rexx < prev    next >
OS/2 REXX Batch file  |  1995-09-04  |  9KB  |  326 lines

  1. /* ADRTCDROM Utility Written by Andrew Rooney (c) 1995 ADRT Software
  2.    UnderWorld Elements BBS (403)346-1816
  3.    $VER: ADRTCDROM 2.9 (3.8.95) (c) 1995 ADRT Software
  4. */
  5.  
  6. if ~show("L","mebbsarexx.library") then do;call addlib("mebbsarexx.library",0,-30,0);end
  7.  
  8. Signal ON ERROR;Signal ON SYNTAX;Signal ON IOERR
  9. Parse Arg Line freqlist .;Door = "ADRTCDROM"
  10.  
  11. Call Pragma("W","N")
  12. if upper(line) = "LIST" | upper(line) = "GUIDE" then Signal ON break_c
  13. if upper(line) = "LIST" | upper(line) = "GUIDE" then call findcd
  14.  
  15. Call GetVar Door,Line,20;access = Result
  16. Call GetVar Door,Line,8;Mode = Result
  17. Call GetVar Door,Line,10;Hight = Result
  18.  
  19.  
  20. ESC = "1B"x
  21. RED = "";GRN = "";YLW = "";BLU = "";PUR = "";CYN = "";WHT = ""
  22. If Mode = 1 then do
  23.  RED = ESC"[31m";GRN = ESC"[32m";YLW = ESC"[33m";BLU = ESC"[34m";PUR = ESC"[35m";CYN = ESC"[36m";WHT = ESC"[37m"
  24. End
  25.  
  26. findcd:
  27. f=0
  28. Do i = 1 to 300
  29.  If Exists("MEBBSNet:Rexx/ADRTCDROM/"i".cfg") then do
  30.   Call Open config, ("MEBBSNet:Rexx/ADRTCDROM/"i".cfg"), "R"
  31.   DLAccess = readln(config)
  32.   readaccess = readln(config)
  33.   CD = readln(config)
  34.   If exists(CD) then do
  35.    CDDesc = readln(config)
  36.    ListType = readln(config)
  37.    Do while ~EOF(config)
  38.     f = f + 1
  39.     AreaDesc.f = readln(config)
  40.     ListPath.f = readln(config)
  41.     FilePath.f = readln(config)
  42.    End
  43.    call close(config)
  44.    call begin
  45.   End
  46.  End
  47.  Call Close(config)
  48. End
  49.  
  50. if upper(line) = "LIST" | upper(line) = "GUIDE" then do
  51.  Say;Say 'There is currently no configured CD-ROM in the Drive...';say
  52.  Exit
  53. End
  54.  
  55. Call Message Door,Line,"0c"x""YLW""Centre("Sorry, No CD Available At This Time",79),1
  56. Call Message Door,Line,,1
  57. Call Hotkey Door,Line,WHT"Press Any Key to Continue..."
  58. call ERROR
  59.  
  60. Begin:
  61. if upper(line) = "LIST" | upper(line) = "GUIDE" Then call MakeList
  62. if access < readaccess then call noaccess
  63. Call Message Door,Line,"0c"x,0
  64. Call Message Door,Line,YLW""Centre("ADRT MEBBSNet CD-ROM Download Utility v2.9",79),1
  65. Call Message Door,Line,BLU""Centre("Written By Andrew Rooney",79),1
  66. Call Message Door,Line,"",1
  67. Call Message Door,Line,BLU"Name Of CD : "WHT""Left(CD,Length(CD)-1),1
  68. Call Message Door,Line,BLU"Description: "WHT""CDDesc,1
  69. Call Message Door,Line,"",1 ; Call Message Door,Line,"",1
  70. disp = 0 ; count = 0
  71. Do m = 1 to f
  72.  disp = disp + 1
  73.  if length(m) = 1 then do
  74.   Call Message Door,Line," ",0
  75.  end
  76.  Call Message Door,Line,BLU"["WHT""m""BLU"] "WHT""Left(AreaDesc.m,25)"         ",0
  77.  If disp = 2 then do
  78.   Call Message Door,Line,"",1 ; disp = 0
  79.   count = count + 1
  80.    If count = Hight then do
  81.      Call Hotkey Door,Line,"More? (Y/n) "
  82.      if Upper(result) = "N" then call CDPrompt
  83.      count = 0
  84.    End
  85.  End
  86. End
  87. Call Message Door,Line,"",1
  88. CDPrompt:
  89. Call Message Door,Line,"",1
  90. Call Message Door,Line,GRN"["WHT"S"GRN"]"WHT"earch for file",1
  91. Call Message Door,Line,,1
  92. Call Prompt Door,Line,YLW"Selection? [RETURN]=Quit: ",7
  93. z = result
  94.  
  95. if z = "NULL" then Call ERROR
  96.  
  97. if upper(z) = "S" then call Search
  98. if z = 0 then call CDPrompt;if z < 0 then call CDPrompt;if z > f then call CDPrompt
  99.  
  100. Path = FilePath.z;List = ListPath.z
  101.  
  102.  
  103. If mode = 1 then do
  104.  Call Message Door,Line,"0c"x,0
  105. End
  106.  
  107. If Upper(ListType) = "FILESBBS" then do
  108.  call open FileList, (List), "R"
  109.  b = 0 ; count = 0
  110.  FileString = ReadLn(FileList)
  111.   Do while ~EOF(FileList)
  112.    b = b + 1
  113.    NMBR = b
  114.    Filename.b = left(FileString,26) ; Desc.b = right(FileString,46)
  115.    if length(b) = 1 then do
  116.     call message Door,Line," ",0
  117.    end
  118.    Call Message Door,Line,BLU"["WHT""NMBR""BLU"] "GRN""FileName.b""CYN""Desc.b,1
  119.    count = count + 1
  120.    If count = Hight then do
  121.     Call Hotkey Door,Line,YLW"More? (Y/n) "
  122.     if upper(result) = "N" then call DLPrompt
  123.     Call Message Door,Line,"",1
  124.     count = 0
  125.    End
  126.    FileString = ReadLn(FileList)
  127.   End
  128. End
  129.  
  130. If Upper(ListType) = ADRTCD then do
  131.  call open FileList, (List), "R"
  132.  b = 0 ; count = 0
  133.   Filename.b = ReadLn(FileList)
  134.   Desc.b = Readln(FileList)
  135.   Do while ~EOF(FileList)
  136.    b = b + 1
  137.    if length(b) = 1 then do
  138.     call message Door,Line," ",0
  139.    end
  140.    Filename.b = left(FileName.b,26) ; Desc.b = right(Desc.b,46)
  141.    Call Message Door,Line,BLU"["WHT""b""BLU"] "GRN""FileName.b""CYN""Desc.b
  142.    count = count + 1
  143.    If count = Hight then do
  144.     Call Hotkey Door,Line,YLW"More? (Y/n) "
  145.     if upper(result) = "N" then call DLPrompt
  146.     count = 0
  147.    End
  148.    Filename.b = ReadLn(FileList)
  149.    Desc.b = Readln(FileList)
  150.   End
  151. End
  152.  
  153. DLPrompt:
  154. call close(FileList)
  155. Call Prompt Door,Line,WHT"Enter Filename or # ",30;v = result
  156.  
  157. If access < dlaccess then do
  158.  call Message Door,Line,"0c"x,0
  159.  Call Message Door,Line,,1
  160.  Call Message Door,Line,,1
  161.  Call Message Door,Line,RED"You do not have access to Download Files on this CD-ROM",1
  162.  Call Message Door,Line,RED"Your Access: "WHT""access""RED" Access Required: "WHT""dlaccess,1
  163.  Call Message Door,Line,,1
  164.  Call hotkey Door,Line,GRN"Press Any key to Continue..."
  165.  Call Begin
  166. End
  167.  
  168. If datatype(v) = "NUM" then do
  169.  DLFile = FileName.v
  170.  DLFile = Strip(DLFile)
  171. End
  172. If datatype(v) = "CHAR" then DLFile = v
  173. If DLFile = "NULL" then call Begin
  174.  
  175. Call SendBinFile Door,Line,Path""DLFile;Call DLPrompt
  176.  
  177.  
  178. Search:
  179. Call Prompt Door,Line,GRN"Search For: "WHT,20
  180. searchfile=result;count=0;lines=0;found=0
  181. if searchfile = "NULL" then call begin
  182. Do m = 1 to f
  183.  Call Message Door,Line,"0c"x,0
  184.  call message Door,Line,WHT"Searching Area #"m""WHT" ("GRN""areadesc.m""WHT") for "WHT"'"BLU""searchfile""WHT"'...",1
  185.  call open filelist, (listpath.m), "R"
  186.  Do while ~EOF(filelist)
  187.   If upper(listtype) = "ADRTCD" then do
  188.    first=readln(filelist);last=readln(filelist)
  189.    scanline = first" "last
  190.   End
  191.   If upper(listtype) = "FILESBBS" then do
  192.    scanline = readln(filelist)
  193.    first = left(scanline,26);last = right(scanline,50)
  194.    scanline = first"   "last
  195.   End
  196.   If Index(upper(scanline),upper(searchfile)) ~= 0 then do
  197.    count=count+1;lines=lines+1;found = 1
  198.    Call Message Door,Line,CYN""left(scanline,79),1
  199.    If Lines = Hight then do
  200.     Call Hotkey Door,Line,GRN"More? "WHT"("GRN"Y"WHT"/"GRN"n"WHT"/"GRN"q"WHT") "
  201.     If upper(result) = "N" then quitting = 1
  202.     If upper(result) = "Q" then do
  203.       Call close(filelist);call begin
  204.     End
  205.     If quitting = 1 then leave
  206.     Call Message Door,Line,,1
  207.     lines = 0
  208.    End
  209.    If quitting = 1 then leave
  210.   End
  211.   If quitting = 1 then leave
  212.  End
  213.  If m=f then do
  214.   If found = 0 then do
  215.    call message door,line,,1;call message door,line,BLU"Could not find '"WHT""searchfile""BLU"'",1;count = 1
  216.   End
  217.  End
  218.  lines = 0
  219.  If count > 0 then do
  220.   Call Hotkey Door,Line,GRN"Q to quit, any other key to continue...";if upper(result)="Q" then call begin
  221.  End
  222.  Call close(filelist);count=0;quitting = 0
  223. End
  224.  
  225. call begin
  226.  
  227. NoView:
  228. call Message Door,Line,"0c"x,0
  229. Call Message Door,Line,,1
  230. Call Message Door,Line,,1
  231. Call Message Door,Line,RED"You do not have access to View Files on this CD-ROM",1
  232. Call Message Door,Line,RED"Your Access: "WHT""access""RED" Access Required: "WHT""viewaccess,1
  233. Call Message Door,Line,,1
  234. Call hotkey Door,Line,GRN"Press Any key to Continue..."
  235. Call Begin
  236.  
  237. noaccess:
  238. call Message Door,Line,"0c"x,0
  239. Call Message Door,Line,,1
  240. Call Message Door,Line,,1
  241. Call Message Door,Line,RED"You do not have access to this CD-ROM",1
  242. Call Message Door,Line,RED"Your Access: "WHT""access""RED" Access Required: "WHT""readaccess,1
  243. Call Message Door,Line,,1
  244. Call hotkey Door,Line,GRN"Press Any key to Continue..."
  245. Call Error
  246.  
  247. MakeList:
  248. m=0
  249. Say;Say "ADRTCDROM v2.9 (c) 1995 ADRT Software. Written by Andrew Rooney"
  250. Say;Say 'Generating File List: 'freqlist;Say
  251. If ~Exists(freqlist) then do;Say;Say 'Cannot find your files listing! Check your path.';say;Exit;End
  252. if upper(line) = "GUIDE" then call GENGuide
  253.  
  254. Call Open(file,freqlist,"A")
  255. Call Writeln(file,"-----------------------------------------------------------------------------")
  256. Call Writeln(file,Centre("ADRTCDROM v2.9 File List (c) 1995 ADRT Software. Written by Andrew Rooney",79))
  257. Call Writeln(file,Centre("File listing for Current CD Available",79))
  258. Call Writeln(file,"")
  259. Call Writeln(file,Centre(CDDesc,79))
  260. Call Writeln(file,"-----------------------------------------------------------------------------")
  261. Do i = 1 to f
  262.  Call Open(listing,listpath.i)
  263.  Call Writeln(file,"")
  264.  Call Writeln(file,"CD-ROM Area #"i" --> ["areadesc.i"]")
  265.  Call Writeln(file,"")
  266.  Do while ~EOF(listing)
  267.  If exists(listpath.i) then do
  268.    If upper(listtype) = "FILESBBS" then do
  269.     m = m+1
  270.     Text.m = readln(listing)
  271.    End
  272.    If upper(listtype) = "ADRTCD" then do
  273.     filename = readln(file);desc = readln(file)
  274.     m = m+1
  275.     Text.m = filename"  "desc
  276.    End
  277.   End
  278.  End
  279. Do p = 1 to m
  280.    if length(text.p) > 2 then do;call writeln(file,text.p);end
  281. End
  282. m=0
  283. call close listing
  284. End
  285. Say "Done!"
  286. Exit
  287.  
  288. GENGuide:
  289. Call Open(file,freqlist,"A")
  290. Do i = 1 to f
  291.  Call Open(listing,listpath.i)
  292.  Call Writeln(file,"AREA [CD-ROM] "areadesc.i)
  293.  Do while ~EOF(listing)
  294.  If exists(listpath.i) then do
  295.    If upper(listtype) = "FILESBBS" then do
  296.     m = m+1
  297.     Text.m = readln(listing)
  298.     if length(text.m) < 1 then leave
  299.     Parse Var Text.m filename ver size desc
  300.     size = left(size,length(size)-1)
  301.     Text.m = "FILE "filename" "size" "desc
  302.    End
  303.    If upper(listtype) = "ADRTCD" then do
  304.     filename = readln(file);desc = readln(file)
  305.     m = m+1
  306.     Text.m = filename" ?? "desc
  307.     if length(filename) < 1 then leave
  308.    End
  309.   End
  310.  End
  311. Do p = 1 to m
  312.    if length(text.p) > 2 then do;call writeln(file,text.p);end
  313. End
  314. m=0
  315. call close listing
  316. End
  317. Say "Done!"
  318. Exit
  319.  
  320.  
  321.  
  322. ERROR:;SYNTAX:;IOERR:
  323. Call Exit_Door Door,Line;Exit
  324.  
  325. break_c:
  326. Say '***BREAK';say 'ADRTCDROM Exiting!';Exit